<template>
	<view class="my_cabinet">
		<uv-navbar placeholder autoBack bgColor="#CA1C1D">
			<template v-slot:left>
				<view class="left_slot">
					<image src="@/static/images/back.png"></image>
				</view>
			</template>
			<template v-slot:center>
				<view class="nav_title">凤寰数字科技商城</view>
			</template>
		</uv-navbar>
		<view class="header">
			<view class="title">
				<image src="@/static/images/m4.png"></image>
				<text>我的仓库</text>
			</view>

			<view class="label">
				<view class="item" @click="router('/pages/cabinet/record')">
					<image src="@/static/images/m33.png"></image>
					<text>记录</text>
				</view>
				<view class="item" @click="router('/pages/cabinet/guide')">
					<image src="@/static/images/m34.png"></image>
					<text>指南</text>
				</view>
			</view>
		</view>
		<view class="head">酒水 {{all_number}}</view>
		<view class="tabs">
			<view class="item" :class="active==1?'active':''" @click="change(1)">库存</view>
			<view class="item" :class="active==2?'active':''" @click="change(2)">待增益</view>
			<view class="item" :class="active==3?'active':''" @click="change(3)">已结束</view>
		</view>
		<component :is="currentComponent" @value="(val)=>all_number=val" :type="active" />
	</view>
</template>

<script setup>
	import List from "@/components/cabinet/List.vue";
	import IncomeList from "@/components/cabinet/IncomeList.vue";
	import EndList from "@/components/cabinet/EndList.vue";
	import useBase from "@/hooks/useBase.js";
	const {
		router
	} = useBase();

	import {
		onShow
	} from "@dcloudio/uni-app";
	import {
		ref,
		shallowRef
	} from "vue";

	const all_number = ref();

	const currentComponent = shallowRef(List);
	const active = ref(1);
	const change = (value) => {
		active.value = value;
		if (value == 1) {
			currentComponent.value = List;
		}
		if (value == 2) {
			currentComponent.value = IncomeList;
		}
		if (value == 3) {
			currentComponent.value = EndList;
		}
	};
	const routerBack = () => uni.navigateBack();
</script>

<style scoped lang="scss">
	.my_cabinet {
		min-height: calc(100vh - var(--window-top) - var(--window-bottom));
		background-color: #f5f5f5;

		.left_slot {
			image {
				width: 43rpx;
				height: 36rpx;
			}
		}

		.nav_title {
			color: #F5F5F5;
			font-size: 36rpx;
		}

		.header {
			width: 100%;
			height: 144rpx;
			padding: 0rpx 30rpx;
			box-sizing: border-box;
			background: url(@/static/images/bg5.png) no-repeat;
			background-position: 0 -536rpx;
			background-size: 100% auto;
			display: flex;
			justify-content: space-between;
			align-items: center;


			.title {
				padding-left: 10rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;

				image {
					width: 42rpx;
					height: 42rpx;
				}

				text {
					color: #fff;
					font-size: 36rpx;
					font-weight: bold;
				}
			}

			.label {
				width: 262rpx;
				height: 88rpx;
				border-radius: 44rpx;
				border: 2rpx solid #FFFFFF;
				box-sizing: border-box;
				background: rgba(255, 255, 255, 0.2);
				display: flex;


				.item {
					flex: 1;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					&:first-child {
						position: relative;

						&::after {
							content: "";
							width: 2rpx;
							height: 40rpx;
							background: #FFFFFF;
							position: absolute;
							right: 0;
							top: 50%;
							transform: translate(-50%, -50%);
							z-index: 2;
						}
					}

					image {
						width: 28rpx;
						height: 28rpx;
					}

					text {
						color: #FFFFFF;
						font-size: 24rpx;
						padding-top: 10rpx;
						box-sizing: border-box;
					}
				}
			}
		}

		.head {
			color: #333333;
			font-size: 36rpx;
			font-weight: bold;
			padding: 30rpx 0 30rpx 60rpx;
			box-sizing: border-box;
			position: relative;

			&::after {
				content: "";
				width: 8rpx;
				height: 34rpx;
				background: #CA1C1D;
				position: absolute;
				left: 40rpx;
				top: 50%;
				transform: translateY(-50%);
			}
		}

		.tabs {
			padding: 0 30rpx 30rpx;
			box-sizing: border-box;
			display: flex;

			.item {
				width: 200rpx;
				height: 60rpx;
				line-height: 60rpx;
				text-align: center;
				color: #666666;
				font-size: 26rpx;
				border-radius: 10rpx;
				margin-right: 20rpx;
				background: #EEEEEE;

				&.active {
					color: #FFFFFF;
					background: #CA1C1D;
				}
			}
		}
	}
</style>